﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Collections.Specialized;
using PreeRegisterModel;
using PreeRegisterBLL;
using PreeRegisterBLL.Security;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;

namespace PreeRegister_WebAPI.Controllers
{
    public class searchController : ApiController
    {
        [HttpPost]
        /// <summary>
        /// 查询缴费项
        /// </summary>
        /// <param name="any"></param>
        /// <returns></returns>
        public EncodeModel notpay(NameValueCollection any)
        {
            try
            {
                //获取JSON加密参数
                string jsonData = CommonBLL.RequestGetParam("jsonData").ToString();

                NotPayResponseModel notPayResponseModel = new NotPayResponseModel();

                //解密头和内容信息
                string head_json = "";
                string body_json = "";
                string head_json_encode = "";
                string body_json_encode = "";
                head_json_encode = head_json = CommonBLL.RequestGetParam("head").ToString();
                body_json_encode = body_json = CommonBLL.RequestGetParam("body").ToString();
                //入口参数日志
                CommonBLL.WriteLog("search|notpay|Post|\r\n" + body_json + "\r\n\r\n");

                jsonData += "{";
                jsonData += string.Format("\"head\":\"{0}\",\"body\":\"{1}\"", head_json, body_json);
                jsonData += "}";
                string ErrMsg = "";
                string ReturnBodyJson = "";
                if (!ResultDecode.DecodeResult(jsonData, "search|notpay", ref head_json, ref body_json, ref ErrMsg))
                {
                    //序列化返回内容类
                    ReturnBodyJson = csSerialize.NotPayResponseModel(notPayResponseModel);

                    //加密返回内容Json
                    return ResultDecode.EncodeResult(ReturnBodyJson);
                }

                //入口参数日志
                CommonBLL.WriteLog("search|notpay|Post|\r\n" + body_json + "\r\n\r\n");

                //反序列化请求字符串
                NotPayRequestModel notPayRequestModel = csSerialize.notPayRequestModel(body_json);

                if (!string.Equals(notPayRequestModel.cateid, "1"))
                {
                    CommonBLL.WriteLog("查询待缴费项，业务类型：" + notPayRequestModel.cateid + "\r\n\r\n");
                    string json_patientUpdate = "head=" + head_json_encode + "&body=" + body_json_encode;

                    string returnStr = ChangZhiHePingBLL.Transparent(json_patientUpdate, "search/notpay");
                    JObject returnObj = JObject.Parse(returnStr);// (JObject)JsonConvert.DeserializeObject(returnStr);
                    string bodyStr = returnObj["body"].ToString();
                    bodyStr = System.Web.HttpUtility.UrlEncode(bodyStr);

                    return ResultDecode.EncodeResult2(bodyStr);
                }
                else
                {
                    //查询缴费项
                    notPayResponseModel = SearchBLL.NotPay_CZHP_New(notPayRequestModel);

                    //序列化返回内容类
                    ReturnBodyJson = csSerialize.NotPayResponseModel(notPayResponseModel);

                    //返回参数日志
                    CommonBLL.WriteLog("search|notpay|Return|\r\n" + ReturnBodyJson + "\r\n\r\n");

                    return ResultDecode.EncodeResult(ReturnBodyJson);
                }

            }
            catch (Exception err)
            {
                NotPayResponseModel notPayResponseModel = new NotPayResponseModel();

                //序列化返回内容类
                string ReturnBodyJson = csSerialize.NotPayResponseModel(notPayResponseModel);

                //返回参数日志
                CommonBLL.WriteLog("search|notpay|Return|\r\n" + ReturnBodyJson + "\r\n\r\n");

                //加密返回内容Json
                return ResultDecode.EncodeResult(ReturnBodyJson);
            }
        }

        [HttpPost]
        /// <summary>
        /// 门诊患者查询
        /// </summary>
        /// <param name="any"></param>
        /// <returns></returns>
        public EncodeModel outPatient(NameValueCollection any)
        {
            try
            {
                //获取JSON加密参数
                string jsonData = CommonBLL.RequestGetParam("jsonData").ToString();

                //解密头和内容信息
                string head_json = "";
                string body_json = "";
                head_json = CommonBLL.RequestGetParam("head").ToString();
                body_json = CommonBLL.RequestGetParam("body").ToString();
                string json_patientUpdate = "head=" + head_json + "&body=" + body_json;

                string returnStr = ChangZhiHePingBLL.Transparent(json_patientUpdate, "search/outpatient");
                JObject returnObj = JObject.Parse(returnStr);// (JObject)JsonConvert.DeserializeObject(returnStr);
                string bodyStr = returnObj["body"].ToString();
                bodyStr = System.Web.HttpUtility.UrlEncode(bodyStr);
                CommonBLL.WriteLog(string.Format("新接口透传，UrlEncode: \r\n{0}\r\n", bodyStr));
                return ResultDecode.EncodeResult2(bodyStr);
            }
            catch (Exception err)
            {
                //序列化返回内容类
                string ReturnBodyJson = err.Message;
                //加密返回内容Json
                return ResultDecode.EncodeResult(ReturnBodyJson);
            }
        }

        [HttpPost]
        /// <summary>
        /// 订单支付状态查询
        /// </summary>
        /// <param name="any"></param>
        /// <returns></returns>
        public EncodeModel orderpaystatus(NameValueCollection any)
        {
            try
            {
                //获取JSON加密参数
                string jsonData = CommonBLL.RequestGetParam("jsonData").ToString();

                //解密头和内容信息
                string head_json = "";
                string body_json = "";
                head_json = CommonBLL.RequestGetParam("head").ToString();
                body_json = CommonBLL.RequestGetParam("body").ToString();
                string json_patientUpdate = "head=" + head_json + "&body=" + body_json;

                string returnStr = ChangZhiHePingBLL.Transparent(json_patientUpdate, "search/orderpaystatus");

                JObject returnObj = JObject.Parse(returnStr);// (JObject)JsonConvert.DeserializeObject(returnStr);
                string bodyStr = returnObj["body"].ToString();
                bodyStr = System.Web.HttpUtility.UrlEncode(bodyStr);

                return ResultDecode.EncodeResult2(bodyStr);
            }
            catch (Exception err)
            {
                //序列化返回内容类
                string ReturnBodyJson = err.Message;
                //加密返回内容Json
                return ResultDecode.EncodeResult(ReturnBodyJson);
            }
        }


        [HttpPost]
        /// <summary>
        /// 查询交易流水
        /// </summary>
        /// <param name="any"></param>
        /// <returns></returns>
        public EncodeModel tradeflow(NameValueCollection any)
        {
            try
            {
                //获取JSON加密参数
                string jsonData = CommonBLL.RequestGetParam("jsonData").ToString();

                //解密头和内容信息
                string head_json = "";
                string body_json = "";
                head_json = CommonBLL.RequestGetParam("head").ToString();
                body_json = CommonBLL.RequestGetParam("body").ToString();
                string json_patientUpdate = "head=" + head_json + "&body=" + body_json;

                string returnStr = ChangZhiHePingBLL.Transparent(json_patientUpdate, "search/tradeflow");
                JObject returnObj = JObject.Parse(returnStr);// (JObject)JsonConvert.DeserializeObject(returnStr);
                string bodyStr = returnObj["body"].ToString();
                bodyStr = System.Web.HttpUtility.UrlEncode(bodyStr);

                return ResultDecode.EncodeResult2(bodyStr);
            }
            catch (Exception err)
            {
                //序列化返回内容类
                string ReturnBodyJson = err.Message;
                //加密返回内容Json
                return ResultDecode.EncodeResult(ReturnBodyJson);
            }
        }


        /// <summary>
        /// 查询订单状态 中间表 hars_appointmentrecord hars_notifyhistask
        /// </summary>
        /// <param name="any"></param>
        /// <returns></returns>
        public EncodeModel payorder(NameValueCollection any)
        {
            try
            {
                //获取JSON加密参数
                string jsonData = CommonBLL.RequestGetParam("jsonData").ToString();

                PayOrderResponseModel payOrderResponseModel = new PayOrderResponseModel();

                //解密头和内容信息
                string head_json = "";
                string body_json = "";
                head_json = CommonBLL.RequestGetParam("head").ToString();
                body_json = CommonBLL.RequestGetParam("body").ToString();
                //入口参数日志
                CommonBLL.WriteLog("search|payOrder|Post|\r\n" + body_json + "\r\n\r\n");

                jsonData += "{";
                jsonData += string.Format("\"head\":\"{0}\",\"body\":\"{1}\"", head_json, body_json);
                jsonData += "}";
                string ErrMsg = "";
                string ReturnBodyJson = "";
                if (!ResultDecode.DecodeResult(jsonData, "search|payOrder", ref head_json, ref body_json, ref ErrMsg))
                {
                    //序列化返回内容类
                    ReturnBodyJson = csSerialize.PayOrderResponseModel(payOrderResponseModel);

                    //加密返回内容Json
                    return ResultDecode.EncodeResult(ReturnBodyJson);
                }

                //入口参数日志
                CommonBLL.WriteLog("search|payOrder|Post|\r\n" + body_json + "\r\n\r\n");

                //反序列化请求字符串
                PayOrderRequestModel payOrderRequestModel = csSerialize.PayOrderRequestModel(body_json);

                //查询订单状态
                payOrderResponseModel = SearchBLL.PayOrder(payOrderRequestModel);

                //序列化返回内容类
                ReturnBodyJson = csSerialize.PayOrderResponseModel(payOrderResponseModel);

                //返回参数日志
                CommonBLL.WriteLog("search|payOrder|Return|\r\n" + ReturnBodyJson + "\r\n\r\n");

                return ResultDecode.EncodeResult(ReturnBodyJson);
            }
            catch (Exception err)
            {
                PayOrderResponseModel payOrderResponseModel = new PayOrderResponseModel();
                //序列化返回内容类
                string ReturnBodyJson = csSerialize.PayOrderResponseModel(payOrderResponseModel);

                //返回参数日志
                CommonBLL.WriteLog("search|payOrder|Return|\r\n" + ReturnBodyJson + "\r\n\r\n");

                //加密返回内容Json
                return ResultDecode.EncodeResult(ReturnBodyJson);
            }
        }

        //public string sqlGet(NameValueCollection any)
        //{

        //    try
        //    {
        //        //获取JSON加密参数
        //        string jsonData = CommonBLL.RequestGetParam("jsonData").ToString();

        //        PayOrderResponseModel payOrderResponseModel = new PayOrderResponseModel();

        //        //解密头和内容信息
        //        string head_json = "";
        //        string body_json = "";
        //        head_json = CommonBLL.RequestGetParam("head").ToString();
        //        body_json = CommonBLL.RequestGetParam("body").ToString();
        //        //入口参数日志
        //        CommonBLL.WriteLog("search|sqlGet|Post|\r\n" + body_json + "\r\n\r\n");

        //        jsonData += "{";
        //        jsonData += string.Format("\"head\":\"{0}\",\"body\":\"{1}\"", head_json, body_json);
        //        jsonData += "}";
        //        string ReturnBodyJson = "";

        //        //反序列化请求字符串
        //        PayOrderRequestModel payOrderRequestModel = csSerialize.PayOrderRequestModel(body_json);

        //        //查询订单状态
        //        payOrderResponseModel = SearchBLL.PayOrder(payOrderRequestModel);

        //        //序列化返回内容类
        //        ReturnBodyJson = csSerialize.PayOrderResponseModel(payOrderResponseModel);

        //        //返回参数日志
        //        CommonBLL.WriteLog("search|payOrder|Return|\r\n" + ReturnBodyJson + "\r\n\r\n");

        //        return  ReturnBodyJson;
        //    }
        //    catch (Exception err)
        //    {
        //        PayOrderResponseModel payOrderResponseModel = new PayOrderResponseModel();
        //        //序列化返回内容类
        //        string ReturnBodyJson = csSerialize.PayOrderResponseModel(payOrderResponseModel);

        //        //返回参数日志
        //        CommonBLL.WriteLog("search|payOrder|Return|\r\n" + ReturnBodyJson + "\r\n\r\n");

        //        //加密返回内容Json
        //        return ResultDecode.EncodeResult(ReturnBodyJson);
        //    }
        //}

        [HttpPost]
        /// <summary>
        /// 查询住院患者信息
        /// </summary>
        /// <param name="any"></param>
        /// <returns></returns>
        public EncodeModel inPatient(NameValueCollection any)
        {
            try
            {
                //获取JSON加密参数
                string jsonData = CommonBLL.RequestGetParam("jsonData").ToString();

                ParentInfoResponseModel parentInfoResponseModel = new ParentInfoResponseModel();

                //解密头和内容信息
                string head_json = "";
                string body_json = "";
                head_json = CommonBLL.RequestGetParam("head").ToString();
                body_json = CommonBLL.RequestGetParam("body").ToString();
                //入口参数日志
                CommonBLL.WriteLog("search|inPatient|Post|\r\n" + body_json + "\r\n\r\n");

                jsonData += "{";
                jsonData += string.Format("\"head\":\"{0}\",\"body\":\"{1}\"", head_json, body_json);
                jsonData += "}";
                string ErrMsg = "";
                string ReturnBodyJson = "";
                if (!ResultDecode.DecodeResult(jsonData, "search|inPatient", ref head_json, ref body_json, ref ErrMsg))
                {
                    //序列化返回内容类
                    ReturnBodyJson = csSerialize.ParentInfoResponseModel(parentInfoResponseModel);

                    //加密返回内容Json
                    return ResultDecode.EncodeResult(ReturnBodyJson);
                }

                //入口参数日志
                CommonBLL.WriteLog("search|inPatient|Post|\r\n" + body_json + "\r\n\r\n");

                //反序列化请求字符串
                ParentInfoRequestModel parentInfoRequestModel = csSerialize.ParentInfoRequestModel(body_json);

                //查询住院患者信息
                parentInfoResponseModel = SearchBLL.GetParentInfo(parentInfoRequestModel);

                //序列化返回内容类
                ReturnBodyJson = csSerialize.ParentInfoResponseModel(parentInfoResponseModel);

                //返回参数日志
                CommonBLL.WriteLog("search|inPatient|Return|\r\n" + ReturnBodyJson + "\r\n\r\n");

                return ResultDecode.EncodeResult(ReturnBodyJson);
            }
            catch (Exception err)
            {
                NotPayResponseModel notPayResponseModel = new NotPayResponseModel();
                notPayResponseModel.code = "-1000";
                notPayResponseModel.msg = "住院患者信息查询异常2" + err.Message;
                //序列化返回内容类
                string ReturnBodyJson = csSerialize.NotPayResponseModel(notPayResponseModel);

                //返回参数日志
                CommonBLL.WriteLog("search|inPatient|Return|\r\n" + ReturnBodyJson + "\r\n\r\n");

                //加密返回内容Json
                return ResultDecode.EncodeResult(ReturnBodyJson);
            }
        }

        [HttpPost]
        /// <summary>
        /// 查询就诊状态
        /// </summary>
        /// <param name="any"></param>
        /// <returns></returns>
        public EncodeModel diagnosestate(NameValueCollection any)
        {
            try
            {
                //获取JSON加密参数
                string jsonData = CommonBLL.RequestGetParam("jsonData").ToString();

                DiagnoseStateResponseModel diagnoseStateResponseModel = new DiagnoseStateResponseModel();

                //解密头和内容信息
                string head_json = "";
                string body_json = "";
                string ErrMsg = "";
                string ReturnBodyJson = "";
                if (!ResultDecode.DecodeResult(jsonData, "search|diagnosestate", ref head_json, ref body_json, ref ErrMsg))
                {
                    //序列化返回内容类
                    ReturnBodyJson = csSerialize.DiagnoseStateResponseModel(diagnoseStateResponseModel);

                    //加密返回内容Json
                    return ResultDecode.EncodeResult(ReturnBodyJson);
                }

                //入口参数日志
                CommonBLL.WriteLog("search|diagnosestate|Post|\r\n" + body_json + "\r\n\r\n");

                //反序列化请求字符串
                DiagnoseStateRequestModel diagnoseStateRequestModel = csSerialize.DiagnoseStateRequestModel(body_json);

                //查询就诊状态
                diagnoseStateResponseModel = SearchBLL.DiagnoseState(diagnoseStateRequestModel);

                //序列化返回内容类
                ReturnBodyJson = csSerialize.DiagnoseStateResponseModel(diagnoseStateResponseModel);

                //返回参数日志
                CommonBLL.WriteLog("search|diagnosestate|Return|\r\n" + ReturnBodyJson + "\r\n\r\n");

                return ResultDecode.EncodeResult(ReturnBodyJson);
            }
            catch (Exception err)
            {
                DiagnoseStateResponseModel diagnoseStateResponseModel = new DiagnoseStateResponseModel();

                //序列化返回内容类
                string ReturnBodyJson = csSerialize.DiagnoseStateResponseModel(diagnoseStateResponseModel);

                //返回参数日志
                CommonBLL.WriteLog("search|diagnosestate|Return|\r\n" + ReturnBodyJson + "\r\n\r\n");

                //加密返回内容Json
                return ResultDecode.EncodeResult(ReturnBodyJson);
            }
        }

        [HttpPost]
        /// <summary>
        /// 查询排队叫号
        /// </summary>
        /// <param name="any"></param>
        /// <returns></returns>
        public EncodeModel clinicqueue(NameValueCollection any)
        {
            try
            {
                //获取JSON加密参数
                string jsonData = CommonBLL.RequestGetParam("jsonData").ToString();

                ClinicQueueResponseModel clinicQueueResponseModel = new ClinicQueueResponseModel();

                //解密头和内容信息
                string head_json = "";
                string body_json = "";
                string ErrMsg = "";
                string ReturnBodyJson = "";
                if (!ResultDecode.DecodeResult(jsonData, "search|clinicqueue", ref head_json, ref body_json, ref ErrMsg))
                {
                    //序列化返回内容类
                    ReturnBodyJson = csSerialize.ClinicQueueResponseModel(clinicQueueResponseModel);

                    //加密返回内容Json
                    return ResultDecode.EncodeResult(ReturnBodyJson);
                }

                //入口参数日志
                CommonBLL.WriteLog("search|clinicqueue|Post|\r\n" + body_json + "\r\n\r\n");

                //反序列化请求字符串
                ClinicQueueRequestModel clinicQueueRequestModel = csSerialize.ClinicQueueRequestModel(body_json);

                //查询排队叫号
                clinicQueueResponseModel = SearchBLL.ClinicQueue(clinicQueueRequestModel);

                //序列化返回内容类
                ReturnBodyJson = csSerialize.ClinicQueueResponseModel(clinicQueueResponseModel);

                //返回参数日志
                CommonBLL.WriteLog("search|clinicqueue|Return|\r\n" + ReturnBodyJson + "\r\n\r\n");

                return ResultDecode.EncodeResult(ReturnBodyJson);
            }
            catch (Exception err)
            {
                ClinicQueueResponseModel clinicQueueResponseModel = new ClinicQueueResponseModel();

                //序列化返回内容类
                string ReturnBodyJson = csSerialize.ClinicQueueResponseModel(clinicQueueResponseModel);

                //返回参数日志
                CommonBLL.WriteLog("search|clinicqueue|Return|\r\n" + ReturnBodyJson + "\r\n\r\n");

                //加密返回内容Json
                return ResultDecode.EncodeResult(ReturnBodyJson);
            }
        }

        [HttpPost]
        /// <summary>
        /// 查询门诊已缴费
        /// </summary>
        /// <param name="any"></param>
        /// <returns></returns>
        public EncodeModel clinicfare(NameValueCollection any)
        {
            try
            {
                //获取JSON加密参数
                string jsonData = CommonBLL.RequestGetParam("jsonData").ToString();

                ClinicFareResponseModel clinicFareResponseModel = new ClinicFareResponseModel();

                //解密头和内容信息
                string head_json = "";
                string body_json = "";
                string ErrMsg = "";
                string ReturnBodyJson = "";
                if (!ResultDecode.DecodeResult(jsonData, "search|clinicfare", ref head_json, ref body_json, ref ErrMsg))
                {
                    //序列化返回内容类
                    ReturnBodyJson = csSerialize.ClinicFareResponseModel(clinicFareResponseModel);

                    //加密返回内容Json
                    return ResultDecode.EncodeResult(ReturnBodyJson);
                }

                //入口参数日志
                CommonBLL.WriteLog("search|clinicfare|Post|\r\n" + body_json + "\r\n\r\n");

                //反序列化请求字符串
                ClinicFareRequestModel clinicFareRequestModel = csSerialize.ClinicFareRequestModel(body_json);

                //查询门诊已缴费
                clinicFareResponseModel = SearchBLL.ClinicFare(clinicFareRequestModel);

                //序列化返回内容类
                ReturnBodyJson = csSerialize.ClinicFareResponseModel(clinicFareResponseModel);

                //返回参数日志
                CommonBLL.WriteLog("search|clinicfare|Return|\r\n" + ReturnBodyJson + "\r\n\r\n");

                return ResultDecode.EncodeResult(ReturnBodyJson);
            }
            catch (Exception err)
            {
                ClinicFareResponseModel clinicFareResponseModel = new ClinicFareResponseModel();

                //序列化返回内容类
                string ReturnBodyJson = csSerialize.ClinicFareResponseModel(clinicFareResponseModel);

                //返回参数日志
                CommonBLL.WriteLog("search|clinicfare|Return|\r\n" + ReturnBodyJson + "\r\n\r\n");

                //加密返回内容Json
                return ResultDecode.EncodeResult(ReturnBodyJson);
            }
        }

        [HttpPost]
        /// <summary>
        /// 住院费用查询
        /// </summary>
        /// <param name="any"></param>
        /// <returns></returns>
        public EncodeModel hospitalfare(NameValueCollection any)
        {
            try
            {
                //获取JSON加密参数
                string jsonData = CommonBLL.RequestGetParam("jsonData").ToString();

                HospitalFareResponseModel hospitalFareResponseModel = new HospitalFareResponseModel();

                //解密头和内容信息
                string head_json = "";
                string body_json = "";
                string ErrMsg = "";
                string ReturnBodyJson = "";
                if (!ResultDecode.DecodeResult(jsonData, "search|hospitalfare", ref head_json, ref body_json, ref ErrMsg))
                {
                    //序列化返回内容类
                    ReturnBodyJson = csSerialize.HospitalFareResponseModel(hospitalFareResponseModel);

                    //加密返回内容Json
                    return ResultDecode.EncodeResult(ReturnBodyJson);
                }

                //入口参数日志
                CommonBLL.WriteLog("search|hospitalfare|Post|\r\n" + body_json + "\r\n\r\n");

                //反序列化请求字符串
                HospitalFareRequestModel hospitalFareRequestModel = csSerialize.HospitalFareRequestModel(body_json);

                //住院费用查询
                hospitalFareResponseModel = SearchBLL.HospitalFare(hospitalFareRequestModel);

                //序列化返回内容类
                ReturnBodyJson = csSerialize.HospitalFareResponseModel(hospitalFareResponseModel);

                //返回参数日志
                CommonBLL.WriteLog("search|hospitalfare|Return|\r\n" + ReturnBodyJson + "\r\n\r\n");

                return ResultDecode.EncodeResult(ReturnBodyJson);
            }
            catch (Exception err)
            {
                HospitalFareResponseModel hospitalFareResponseModel = new HospitalFareResponseModel();

                //序列化返回内容类
                string ReturnBodyJson = csSerialize.HospitalFareResponseModel(hospitalFareResponseModel);

                //返回参数日志
                CommonBLL.WriteLog("search|hospitalfare|Return|\r\n" + ReturnBodyJson + "\r\n\r\n");

                //加密返回内容Json
                return ResultDecode.EncodeResult(ReturnBodyJson);
            }
        }

        [HttpPost]
        /// <summary>
        /// 人工窗口退费查询
        /// </summary>
        /// <param name="any"></param>
        /// <returns></returns>
        public EncodeModel windowFadeFare(NameValueCollection any)
        {
            try
            {
                //获取JSON加密参数
                string jsonData = CommonBLL.RequestGetParam("jsonData").ToString();

                WindowFadeFareResponseModel windowFadeFareResponseModel = new WindowFadeFareResponseModel();

                //解密头和内容信息
                string head_json = "";
                string body_json = "";
                string ErrMsg = "";
                string ReturnBodyJson = "";
                if (!ResultDecode.DecodeResult(jsonData, "search|windowFadeFare", ref head_json, ref body_json, ref ErrMsg))
                {
                    //序列化返回内容类
                    ReturnBodyJson = csSerialize.WindowFadeFareResponseModel(windowFadeFareResponseModel);

                    //加密返回内容Json
                    return ResultDecode.EncodeResult(ReturnBodyJson);
                }

                //入口参数日志
                CommonBLL.WriteLog("search|windowFadeFare|Post|\r\n" + body_json + "\r\n\r\n");

                //反序列化请求字符串
                WindowFadeFareRequestModel windowFadeFareRequestModel = csSerialize.WindowFadeFareRequestModel(body_json);

                //人工窗口退费查询
                windowFadeFareResponseModel = SearchBLL.WindowFadeFare(windowFadeFareRequestModel);

                //序列化返回内容类
                ReturnBodyJson = csSerialize.WindowFadeFareResponseModel(windowFadeFareResponseModel);

                //返回参数日志
                CommonBLL.WriteLog("search|windowFadeFare|Return|\r\n" + ReturnBodyJson + "\r\n\r\n");

                return ResultDecode.EncodeResult(ReturnBodyJson);
            }
            catch (Exception err)
            {
                WindowFadeFareResponseModel windowFadeFareResponseModel = new WindowFadeFareResponseModel();

                //序列化返回内容类
                string ReturnBodyJson = csSerialize.WindowFadeFareResponseModel(windowFadeFareResponseModel);

                //返回参数日志
                CommonBLL.WriteLog("search|windowFadeFare|Return|\r\n" + ReturnBodyJson + "\r\n\r\n");

                //加密返回内容Json
                return ResultDecode.EncodeResult(ReturnBodyJson);
            }
        }

        [HttpPost]
        /// <summary>
        /// 门诊费用发票号查询
        /// </summary>
        /// <param name="any"></param>
        /// <returns></returns>
        public EncodeModel clinicFareBillNum(NameValueCollection any)
        {
            try
            {
                //获取JSON加密参数
                string jsonData = CommonBLL.RequestGetParam("jsonData").ToString();

                ClinicFareBillNumResponseModel clinicFareBillNumResponseModel = new ClinicFareBillNumResponseModel();

                //解密头和内容信息
                string head_json = "";
                string body_json = "";
                string ErrMsg = "";
                string ReturnBodyJson = "";
                if (!ResultDecode.DecodeResult(jsonData, "search|clinicFareBillNum", ref head_json, ref body_json, ref ErrMsg))
                {
                    //序列化返回内容类
                    ReturnBodyJson = csSerialize.ClinicFareBillNumResponseModel(clinicFareBillNumResponseModel);

                    //加密返回内容Json
                    return ResultDecode.EncodeResult(ReturnBodyJson);
                }

                //入口参数日志
                CommonBLL.WriteLog("search|clinicFareBillNum|Post|\r\n" + body_json + "\r\n\r\n");

                //反序列化请求字符串
                ClinicFareBillNumRequestModel clinicFareBillNumRequestModel = csSerialize.ClinicFareBillNumRequestModel(body_json);

                //人工窗口退费查询
                clinicFareBillNumResponseModel = SearchBLL.ClinicFareBillNum(clinicFareBillNumRequestModel);

                //序列化返回内容类
                ReturnBodyJson = csSerialize.ClinicFareBillNumResponseModel(clinicFareBillNumResponseModel);

                //返回参数日志
                CommonBLL.WriteLog("search|clinicFareBillNum|Return|\r\n" + ReturnBodyJson + "\r\n\r\n");

                return ResultDecode.EncodeResult(ReturnBodyJson);
            }
            catch (Exception err)
            {
                ClinicFareBillNumResponseModel clinicFareBillNumResponseModel = new ClinicFareBillNumResponseModel();

                //序列化返回内容类
                string ReturnBodyJson = csSerialize.ClinicFareBillNumResponseModel(clinicFareBillNumResponseModel);

                //返回参数日志
                CommonBLL.WriteLog("search|clinicFareBillNum|Return|\r\n" + ReturnBodyJson + "\r\n\r\n");

                //加密返回内容Json
                return ResultDecode.EncodeResult(ReturnBodyJson);
            }
        }

        [HttpPost]
        /// <summary>
        /// 置人工窗口退费流水已获取标志  liujia151208
        /// </summary>
        /// <param name="any"></param>
        /// <returns></returns>
        public EncodeModel setWindowFadeFareFlag(NameValueCollection any)
        {
            try
            {
                //获取JSON加密参数
                string jsonData = CommonBLL.RequestGetParam("jsonData").ToString();

                SetWFFFlagResponseModel setWFFFlagResponseModel = new SetWFFFlagResponseModel();

                //解密头和内容信息
                string head_json = "";
                string body_json = "";
                string ErrMsg = "";
                string ReturnBodyJson = "";
                if (!ResultDecode.DecodeResult(jsonData, "search|setWindowFadeFareFlag", ref head_json, ref body_json, ref ErrMsg))
                {
                    setWFFFlagResponseModel.code = "0";
                    setWFFFlagResponseModel.msg = ErrMsg;

                    //序列化返回内容类
                    ReturnBodyJson = csSerialize.SetWFFFlagResponseModel(setWFFFlagResponseModel);

                    //加密返回内容Json
                    return ResultDecode.EncodeResult(ReturnBodyJson);
                }

                //入口参数日志
                CommonBLL.WriteLog("search|setWindowFadeFareFlag|Post|\r\n" + body_json + "\r\n\r\n");

                //反序列化请求字符串
                SetWFFFlagRequestModel setWFFFlagRequestModel = csSerialize.SetWFFFlagRequestModel(body_json);

                //置人工窗口退费流水已获取标志
                setWFFFlagResponseModel = SearchBLL.SetWFFFlag(setWFFFlagRequestModel);

                //序列化返回内容类
                ReturnBodyJson = csSerialize.SetWFFFlagResponseModel(setWFFFlagResponseModel);

                //返回参数日志
                CommonBLL.WriteLog("search|setWindowFadeFareFlag|Return|\r\n" + ReturnBodyJson + "\r\n\r\n");

                return ResultDecode.EncodeResult(ReturnBodyJson);
            }
            catch (Exception err)
            {
                SetWFFFlagResponseModel setWFFFlagResponseModel = new SetWFFFlagResponseModel();

                setWFFFlagResponseModel.code = "0";
                setWFFFlagResponseModel.msg = err.Message;

                //序列化返回内容类
                string ReturnBodyJson = csSerialize.SetWFFFlagResponseModel(setWFFFlagResponseModel);

                //返回参数日志
                CommonBLL.WriteLog("search|setWindowFadeFareFlag|Return|\r\n" + ReturnBodyJson + "\r\n\r\n");

                //加密返回内容Json
                return ResultDecode.EncodeResult(ReturnBodyJson);
            }
        }

        [HttpPost]
        /// <summary>
        /// 查询挂号记录  liujia151226
        /// </summary>
        /// <param name="any"></param>
        /// <returns></returns>
        public EncodeModel registerrecord(NameValueCollection any)
        {
            try
            {
                //获取JSON加密参数
                string jsonData = CommonBLL.RequestGetParam("jsonData").ToString();

                RegisterRecordResponseModel registerRecordResponseModel = new RegisterRecordResponseModel();

                //解密头和内容信息
                string head_json = "";
                string body_json = "";
                string ErrMsg = "";
                string ReturnBodyJson = "";
                if (!ResultDecode.DecodeResult(jsonData, "search|registerrecord", ref head_json, ref body_json, ref ErrMsg))
                {
                    registerRecordResponseModel.code = "0";
                    registerRecordResponseModel.msg = "查询挂号记录失败：" + ErrMsg;

                    //序列化返回内容类
                    ReturnBodyJson = csSerialize.RegisterRecordResponseModel(registerRecordResponseModel);

                    //加密返回内容Json
                    return ResultDecode.EncodeResult(ReturnBodyJson);
                }

                //入口参数日志
                CommonBLL.WriteLog("search|registerrecord|Post|\r\n" + body_json + "\r\n\r\n");

                //反序列化请求字符串
                RegisterRecordRequestModel registerRecordRequestModel = csSerialize.RegisterRecordRequestModel(body_json);

                //查询挂号记录
                registerRecordResponseModel = SearchBLL.RegisterRecord(registerRecordRequestModel);

                //序列化返回内容类
                ReturnBodyJson = csSerialize.RegisterRecordResponseModel(registerRecordResponseModel);

                //返回参数日志
                CommonBLL.WriteLog("search|registerrecord|Return|\r\n" + ReturnBodyJson + "\r\n\r\n");

                return ResultDecode.EncodeResult(ReturnBodyJson);
            }
            catch (Exception err)
            {
                RegisterRecordResponseModel registerRecordResponseModel = new RegisterRecordResponseModel();

                registerRecordResponseModel.code = "0";
                registerRecordResponseModel.msg = "查询挂号记录失败：" + err.Message;

                //序列化返回内容类
                string ReturnBodyJson = csSerialize.RegisterRecordResponseModel(registerRecordResponseModel);

                //返回参数日志
                CommonBLL.WriteLog("search|registerrecord|Return|\r\n" + ReturnBodyJson + "\r\n\r\n");

                //加密返回内容Json
                return ResultDecode.EncodeResult(ReturnBodyJson);
            }
        }



        [HttpPost]
        /// <summary>
        /// 查询Pacs患者列表
        /// </summary>
        /// <param name="any"></param>
        /// <returns></returns>
        public EncodeModel studyList(NameValueCollection any)
        {
            try
            {

                //获取JSON加密参数
                string head_json = CommonBLL.RequestGetParam("head").ToString();
                string body_json = CommonBLL.RequestGetParam("body").ToString();

                //拼装jsonData类
                EncodeModel encodeModel = new EncodeModel();
                encodeModel.head = head_json;
                encodeModel.body = body_json;

                //转化jsonData串
                string jsonData = csSerialize.ResponseInfo(encodeModel);
                //ReportDetailResponseModel reportDetailResponseModel = new ReportDetailResponseModel();

                //解密头和内容信息
                string ErrMsg = "";
                string ReturnBodyJson = "";

                LocalPacsModel.PacsPatInfoListResponseModel ListResponseModel = new LocalPacsModel.PacsPatInfoListResponseModel();

                if (!ResultDecode.DecodeResult(jsonData, "search|studyList", ref head_json, ref body_json, ref ErrMsg))
                {
                    //序列化返回内容类
                    ReturnBodyJson = csSerialize.PacsPatInfoListResponseModel(ListResponseModel);

                    //加密返回内容Json
                    return ResultDecode.EncodeResult(ReturnBodyJson);
                }

                //入口参数日志
                CommonBLL.WriteLog("search|studyList|Post|\r\n" + body_json + "\r\n\r\n");


                //反序列化请求字符串
                // TODO 反序列化
                LocalPacsModel.PacsPatInfoListByTimeRequestModel ReportListRequestModel = csSerialize.PacsPatInfoListByTimeRequestModel(body_json);

                //查询检验报告列表
                ListResponseModel = LocalPacsBLL.GetLabReportList(ReportListRequestModel);

                LocalPacsModel.InPatResponseModel responseModel = new LocalPacsModel.InPatResponseModel();

                responseModel.code = ListResponseModel.code;
                responseModel.msg = ListResponseModel.msg;

                if (ListResponseModel.result.Count>0)
                {
                    foreach (var item in ListResponseModel.result)
                    {
                        responseModel.result.Add(new LocalPacsModel.InPatModel() { unitId = item.unitId, xeguid = item.applyno });
                    }
                }

                //序列化返回内容类
                ReturnBodyJson = csSerialize.InPatResponseModel(responseModel);

                //返回参数日志
                CommonBLL.WriteLog("search|studyList|Return|\r\n" + ReturnBodyJson + "\r\n\r\n");

                return ResultDecode.EncodeResult(ReturnBodyJson);
            }
            catch (Exception err)
            {
                LabReportListResponseModel labReportListResponseModel = new LabReportListResponseModel();
                labReportListResponseModel.code = "-1000";
                labReportListResponseModel.msg = "获取检验报告异常2：" + err.Message;

                //序列化返回内容类
                string ReturnBodyJson = csSerialize.LabReportListResponseModel(labReportListResponseModel);

                //返回参数日志
                CommonBLL.WriteLog("search|studyList|Return|\r\n" + ReturnBodyJson + "\r\n\r\n");

                //加密返回内容Json
                return ResultDecode.EncodeResult(ReturnBodyJson);
            }
        }
    }
}
